package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Acceptance;
import cn.wolfcode.crm.mapper.AcceptanceMapper;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.query.RequireQueryObject;
import cn.wolfcode.crm.service.IAcceptanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AcceptanceServiceImpl implements IAcceptanceService {

    @Autowired
    private AcceptanceMapper  acceptanceMapper;

    public void insert(Acceptance entity) {
        entity.setInputTime(new Date());
        acceptanceMapper.insert(entity);
    }

    public void delete(Long id) {
         acceptanceMapper.deleteByPrimaryKey(id);
    }

    public void update(Acceptance entity) {
        acceptanceMapper.updateByPrimaryKey(entity);
    }

    public Acceptance get(Long id) {
        return  acceptanceMapper.selectByPrimaryKey(id);
    }

    public List<Acceptance> list() {
        return  acceptanceMapper.selectAll();
    }

    public PageResult query(RequireQueryObject qo) {
        int total =  acceptanceMapper.queryForCount(qo);
        List<Acceptance> rows =  acceptanceMapper.queryForList(qo);
        return new PageResult(total,rows);
    }
}
